//PA2-4
#include "cpu/exec/template-start.h"

#define instr add

static void do_execute() {
    DATA_TYPE result = op_dest->val + op_src->val;
    OPERAND_W(op_dest, result);

    update_eflags_pf_zf_sf((DATA_TYPE_S)result);
    cpu.eflags.CF = result < op_dest->val; /* unsigned carry */
    cpu.eflags.OF = MSB((~(op_dest->val ^ op_src->val)) & (op_dest->val ^ result));

    print_asm_template2();
}

/* imm8 sign-extend to r/m (0x83 /0) — only for 16/32-bit ops */
#if DATA_BYTE == 2 || DATA_BYTE == 4
make_instr_helper(si2rm)
#endif

/* imm to r/m (0x81 /0) */
make_instr_helper(i2rm)

/* r to r/m (0x01) */
make_instr_helper(r2rm)

/* r/m to r (0x03) */
make_instr_helper(rm2r)

/* imm to accumulator (0x05) */
make_instr_helper(i2a)

#include "cpu/exec/template-end.h"


